1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module soup.WebsocketExtension; 26 27 private import glib.Bytes; 28 private import glib.ErrorG; 29 private import glib.GException; 30 private import glib.HashTable; 31 private import glib.Str; 32 private import glib.c.functions; 33 private import gobject.ObjectG; 34 private import soup.c.functions; 35 public import soup.c.types; 36 37 38 /** */ 39 public class WebsocketExtension : ObjectG 40 { 41 /** the main Gtk struct */ 42 protected SoupWebsocketExtension* soupWebsocketExtension; 43 44 /** Get the main Gtk struct */ 45 public SoupWebsocketExtension* getWebsocketExtensionStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return soupWebsocketExtension; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)soupWebsocketExtension; 56 } 57 58 /** 59 * Sets our main struct and passes it to the parent class. 60 */ 61 public this (SoupWebsocketExtension* soupWebsocketExtension, bool ownedRef = false) 62 { 63 this.soupWebsocketExtension = soupWebsocketExtension; 64 super(cast(GObject*)soupWebsocketExtension, ownedRef); 65 } 66 67 68 /** */ 69 public static GType getType() 70 { 71 return soup_websocket_extension_get_type(); 72 } 73 74 /** 75 * Configures @extension with the given @params 76 * 77 * Params: 78 * connectionType = either %SOUP_WEBSOCKET_CONNECTION_CLIENT or %SOUP_WEBSOCKET_CONNECTION_SERVER 79 * params = the parameters, or %NULL 80 * 81 * Returns: %TRUE if extension could be configured with the given parameters, or %FALSE otherwise 82 * 83 * Throws: GException on failure. 84 */ 85 public bool configure(SoupWebsocketConnectionType connectionType, HashTable params) 86 { 87 GError* err = null; 88 89 auto __p = soup_websocket_extension_configure(soupWebsocketExtension, connectionType, (params is null) ? null : params.getHashTableStruct(), &err) != 0; 90 91 if (err !is null) 92 { 93 throw new GException( new ErrorG(err) ); 94 } 95 96 return __p; 97 } 98 99 /** 100 * Get the parameters strings to be included in the request header. If the extension 101 * doesn't include any parameter in the request, this function returns %NULL. 102 * 103 * Returns: a new allocated string with the parameters 104 * 105 * Since: 2.68 106 */ 107 public string getRequestParams() 108 { 109 auto retStr = soup_websocket_extension_get_request_params(soupWebsocketExtension); 110 111 scope(exit) Str.freeString(retStr); 112 return Str.toString(retStr); 113 } 114 115 /** 116 * Get the parameters strings to be included in the response header. If the extension 117 * doesn't include any parameter in the response, this function returns %NULL. 118 * 119 * Returns: a new allocated string with the parameters 120 * 121 * Since: 2.68 122 */ 123 public string getResponseParams() 124 { 125 auto retStr = soup_websocket_extension_get_response_params(soupWebsocketExtension); 126 127 scope(exit) Str.freeString(retStr); 128 return Str.toString(retStr); 129 } 130 131 /** 132 * Process a message after it's received. If the payload isn't changed the given 133 * @payload is just returned, otherwise g_bytes_unref() is called on the given 134 * @payload and a new #GBytes is returned with the new data. 135 * 136 * Extensions using reserved bits of the header will reset them in @header. 137 * 138 * Params: 139 * header = the message header 140 * payload = the payload data 141 * 142 * Returns: the message payload data, or %NULL in case of error 143 * 144 * Since: 2.68 145 * 146 * Throws: GException on failure. 147 */ 148 public Bytes processIncomingMessage(ref ubyte header, Bytes payload) 149 { 150 GError* err = null; 151 152 auto __p = soup_websocket_extension_process_incoming_message(soupWebsocketExtension, &header, (payload is null) ? null : payload.getBytesStruct(true), &err); 153 154 if (err !is null) 155 { 156 throw new GException( new ErrorG(err) ); 157 } 158 159 if(__p is null) 160 { 161 return null; 162 } 163 164 return new Bytes(cast(GBytes*) __p, true); 165 } 166 167 /** 168 * Process a message before it's sent. If the payload isn't changed the given 169 * @payload is just returned, otherwise g_bytes_unref() is called on the given 170 * @payload and a new #GBytes is returned with the new data. 171 * 172 * Extensions using reserved bits of the header will change them in @header. 173 * 174 * Params: 175 * header = the message header 176 * payload = the payload data 177 * 178 * Returns: the message payload data, or %NULL in case of error 179 * 180 * Since: 2.68 181 * 182 * Throws: GException on failure. 183 */ 184 public Bytes processOutgoingMessage(ref ubyte header, Bytes payload) 185 { 186 GError* err = null; 187 188 auto __p = soup_websocket_extension_process_outgoing_message(soupWebsocketExtension, &header, (payload is null) ? null : payload.getBytesStruct(true), &err); 189 190 if (err !is null) 191 { 192 throw new GException( new ErrorG(err) ); 193 } 194 195 if(__p is null) 196 { 197 return null; 198 } 199 200 return new Bytes(cast(GBytes*) __p, true); 201 } 202 }